﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LTHD_Web
{
    public partial class Myplace : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.Cookies["userName"] != null)
            {
                lb_taikhoan.Text = "<a href='Myplace.aspx'  style='color:Green'> " + Request.Cookies["userName"].Value + "</a >";



                int accountid = int.Parse(Request["userid"]);
                string accountname = Request.Cookies["userName"].Value;
                dbDataContext db = new dbDataContext();

                var query = from n in db.diadiems
                            join m in db.linhvucs on n.linhvuc equals m.id
                            where n.taikhoan == accountid && n.status != -1
                            select new
                            {
                                id = n.id,
                                ten = n.ten,
                                longitude = m.tenlinhvuc,
                                diachi = n.diachi,
                                status = n.status,
                                chitiet = n.chitiet,
                            };
                lb_content.Text = "";
                foreach (var n in query)
                {
                    string s = "Create";
                    if (n.status == 2)
                        s = "Like";
                    lb_content.Text += "<div class='one-result' style='height:200px' id='result" + n.id + "'>            <div class='user-picture'> <img src='Images/profile1.jpg' width='60px' />    </div>            <div class='search-info' >             <div class='info-title' > <a href='Discuss.aspx?id=" + n.id + "'>" + n.ten + "</div>       </a >     <div class='info-account' > " + s + "</div>       <div class='info-account' > " + n.longitude + "</div>     <div class='info-account' id=address" + n.id + " >  " + n.diachi + "</div>   <div class='info-account' id=detail" + n.id + "  style='height:95px'>  " + n.chitiet + "</div>                            <div class='info-account'> <a href='#' onclick='editaddress(" + n.id + ")'> Edit address</a > &nbsp;&nbsp;&nbsp; <a href='#' onclick='editdetail(" + n.id + ")'> Edit detail</a > &nbsp;&nbsp;&nbsp; <a href='#' onclick='del(" + n.id + ", " + accountid + ")'> Delete </a > </div >       </div>                        </div>";
                }

            }
            else 
                Response.Redirect("LoginandRegistery.aspx");
        }
    }
}